home *** CD-ROM | disk | FTP | other *** search
- ; Passing Parameters to Assembly: STRING
- ; --------------------------------------
- ;
- ; This procedure sets the appropriate video segment based on the video
- ; adapter installed, then puts the contents of the screen into a string that
- ; is passed from QB.
- ;
-
- .model medium
-
- .code
-
- public ScrSave
- ScrSave proc far
-
- push bp ;
- push ds ;
- push es ;Save the registers for QuickBASIC
- push si ;
- push di ;
-
- mov bp,sp ;use BP as stack index
-
- mov bx,[bp+6] ;Get the address of the BASIC string descriptor
- mov cx,[bx] ;put the length of the passed string in CX
- mov si,[bx+2] ;put the offset of the passed string is SI
-
- Get_Adapter:
-
- mov bx,0 ;
- mov es,bx ;go to low memory
- mov ax,es:[449h] ;put the video mode byte into AX
-
- cmp al,3 ;
- jle CGA ;if mode <= 3 then it is CGA text mode
- cmp al,7 ;
- jz Hercules ;elseif mode = 7 then it is Hercules text mode
- jmp finish ;elseif neither, exit
-
- CGA:
-
- mov bx,0b800h ;put CGA text video segment in BX
- jmp Set_Vid_Seg ;jump over Hercules section
-
- Hercules:
-
- mov bx,0b000h ;put Hercules text video segment in BX
-
- Set_Vid_Seg:
-
- push ds ;save DS
- mov ds,bx ;put the text video segment in DS
- pop es ;put the default data segment in ES
- mov si,0 ;
-
- ;MOVSB is an instruction that MOVes a String Byte from DS:SI to ES:DI
- ;the following repeats the MOVSB instruction the number of times
- ;in CX (CX contains the length of the string passed from QB)
-
- rep movsb
-
- finish: ;wrap it up and restore QB's registers
-
- pop di
- pop si
- pop es
- pop ds
- pop bp
-
- ret 2 ;return and pop 2 bytes off of the stack
- ;(1 integer parameter, 2 bytes, passed from QB)
-
- ScrSave endp
-
- END
-